import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/icons'
import '@/styles/index.scss'
import StatusHtml from '@/directive/status-html'
import DiagDialog from '@/directive/el-drag-dialog'
import { formatDate, isEmpty } from './utils'
import http from '@/utils/request'
import Bus from '@/utils/bus.js'

import Scroll from './components/Scroll/index'
import ElInputLimit from './components/ElInputLimit'
import DateRangePicker from './components/DateRangePicker'

Vue.component('Scroll', Scroll)
Vue.component('ElInputLimit', ElInputLimit)
Vue.component('DateRangePicker', DateRangePicker)

Vue.use(ElementUI)
Vue.use(StatusHtml)
Vue.use(DiagDialog)

Vue.filter('formatDate', function(date, format) {
  if (isEmpty(date)) return '-'
  return formatDate(date, format)
})

Vue.prototype.$jsonCopy = data => JSON.parse(JSON.stringify(data))
Vue.prototype.$http = http
Vue.prototype.$bus = Bus
Vue.prototype.$awitTo = function(promise) {
  return promise.then(res => [res, null]).catch(err => [null, err])
}

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
